package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.entity.DamageList;
import com.atguigu.jxc.service.DamageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/damageListGoods")
//http://localhost:8080/damageListGoods/save?damageNumber=BS1605766644460（报损单号,前端生成）
public class DamageController {
    @Autowired
    private DamageService damageService;

    //http://localhost:8080/damageListGoods/save?damageNumber=BS1605766644460（报损单号,前端生成）
    @PostMapping("/save")
    public ServiceVO save(DamageList damageList, String damageListGoodsStr) {
        this.damageService.save(damageList, damageListGoodsStr);
        return new ServiceVO<>(SuccessCode.SUCCESS_CODE, SuccessCode.SUCCESS_MESS);
    }
    //http://localhost:8080/damageListGoods/goodsList
    @PostMapping("/list")
    public Map<String, Object> save(String sTime, String eTime) {
        return this.damageService.list(sTime,eTime);
    }
    @PostMapping("/goodsList")
    public Map<Object, Object> getListById(Integer damageListId) {
        return this.damageService.getListById(damageListId);
    }
}
